package com.yxw.springmvc.userBehavior.service.impl;

import com.yxw.springmvc.userBehavior.convert.UserRoleConvert;
import com.yxw.springmvc.userBehavior.mapper.UserRoleManageMapper;
import com.yxw.springmvc.userBehavior.model.UserRole;
import com.yxw.springmvc.userBehavior.request.UserRoleAddRequest;
import com.yxw.springmvc.userBehavior.service.UserRoleManageService;
import com.yxw.springmvc.userBehavior.util.CollectionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by hp on 2016/9/27.
 */
@Service
@Slf4j
public class UserRoleManageServiceImpl implements UserRoleManageService {

    @Resource
    private UserRoleManageMapper userRoleManageMapper;

    @Resource
    private UserRoleConvert userRoleConvert;

    @Override
    public UserRole add(UserRoleAddRequest request) {
        if(CollectionUtils.isEmpty(request)){
            return null;
        }
        UserRole role = userRoleConvert.convert(request);
        userRoleManageMapper.add(role);
        return role;
    }
}
